import { Global, Module } from '@nestjs/common';
import { GPTModule } from './gpt/gpt.module';
import { MailModule } from './mail/mail.module';
import { UserModule } from './user/user.module';
import { PrismaService, service } from './prisma.service';
import { AuthModule } from './auth/auth.module';
import { ConfigModule } from '@nestjs/config';
import { CoralClassModule } from './coral-class/coral-class.module';
import { FileUploadModule } from './file-upload/file-upload.module';
import { ServeStaticModule } from '@nestjs/serve-static';
import { ArticleModule } from './article/article.module';
import { ArticleLikeModule } from './article-like/article-like.module';
import { CommentModule } from './comment/comment.module';
import { HomeMediaModule } from './home-media/home-media.module';
import { ArticleViewModule } from './article-view/article-view.module';
import { UserActionModule } from './user-action/user-action.module';
import { PromptModule } from './prompt/prompt.module';

@Global()
@Module({
  imports: [
    GPTModule,
    MailModule,
    UserModule,
    AuthModule,
    ConfigModule.forRoot(),
    CoralClassModule,
    FileUploadModule,
    ServeStaticModule.forRoot({
      rootPath: process.env.STATIC_PATH, // 指向存放静态文件的目录
      serveRoot: '/static/', // 用于访问静态文件的 URL 前缀
    }),
    ArticleModule,
    ArticleLikeModule,
    CommentModule,
    HomeMediaModule,
    ArticleViewModule,
    UserActionModule,
    PromptModule,
  ],
  providers: [
    {
      provide: PrismaService,
      useValue: service,
    },
    ConfigModule,
  ],
  // 这里得export才能全局导出，不然的话其实就是只能在这个模块内使用
  exports: [
    {
      provide: PrismaService,
      useValue: service,
    },
    ConfigModule,
  ],
})
export class AppModule {}
